#include "cipher.h"
#include "addRoundKey.h"
#include "sBoxLayer.h"
#include "pLayer.h"

void cipher(unsigned char *state, unsigned char roundKeys[][8]) {
	for(int i = 0; i < 31; ++i) {
		addRoundKey(state, roundKeys[i]);
		sBoxLayer(state);
		pLayer(state);
	}

	addRoundKey(state, roundKeys[31]);
}

void inv_cipher(unsigned char *state, unsigned char roundKeys[][8]) {
	addRoundKey(state, roundKeys[31]);

	for(int i = 30; i >= 0; --i) {
		inv_pLayer(state);
		inv_sBoxLayer(state);
		addRoundKey(state, roundKeys[i]);
	}
}
